package org.example.coursemangementserver.server.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.coursemangementserver.common.result.Result;
import org.example.coursemangementserver.pojo.dto.IDListDTO;
import org.example.coursemangementserver.pojo.dto.course.StudentCommentCourseDTO;
import org.example.coursemangementserver.pojo.dto.course.StudentCourseCommentListQuery.GetStudentCourseCommentListDTO;
import org.example.coursemangementserver.pojo.dto.course.StudentCourseListQuery.GetStudentCourseListDTO;
import org.example.coursemangementserver.pojo.dto.course.StudentCourseSelectListQuery.GetStudentCourseSelectListDTO;
import org.example.coursemangementserver.pojo.dto.course.StudentDropCourseDTO;
import org.example.coursemangementserver.pojo.dto.course.StudentSelectCourseDTO;
import org.example.coursemangementserver.pojo.dto.student.StudentNewInfoDTO;
import org.example.coursemangementserver.pojo.vo.course.StudentCourseList.StudentCourseListVO;
import org.example.coursemangementserver.pojo.vo.course.StudentSelectCourseList.StudentSelectCourseListVO;
import org.example.coursemangementserver.pojo.vo.course.studentCourseCommentList.StudentCourseCommentListVO;
import org.example.coursemangementserver.pojo.vo.student.StudentInfoVO;
import org.example.coursemangementserver.server.service.interfac.student.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 与学生操作有关的请求
 */
@RestController
@Slf4j
@RequestMapping("/student")
public class studentController {

    @Autowired
    private StudentService studentService;

    /**
     * 学生获取所有可选课程信息的请求
     * @return
     */
    @PostMapping("/getStudentSelectCourseList")
    public Result<StudentSelectCourseListVO>  getStudentSelectCourse(@RequestBody GetStudentCourseSelectListDTO getStudentCourseSelectListDTO){
        StudentSelectCourseListVO studentSelectCourseListVO = studentService.getStudentSelectCourse(getStudentCourseSelectListDTO);
        return Result.success(studentSelectCourseListVO);
    }

    /**
     * 学生选课的请求
     * @return
     */
    @PostMapping("/studentSelectCourse")
    public Result studentSelectCourse(@RequestBody StudentSelectCourseDTO studentSelectCourseDTO){
        studentService.studentSelectCourse(studentSelectCourseDTO);
        return Result.success("选课成功");
    }

    /**
     * 学生批量选课
     * @return
     */
    @PostMapping("/studentSelectCourseOnList")
    public Result studentSelectCourseOnList(@RequestBody IDListDTO idListDTO){
        studentService.selectCourseOnList(idListDTO);
        return Result.success("选课成功");
    }

    /**
     * 学生退课的请求
     * @return
     */
    @PostMapping("/studentDropCourse")
    public Result studentDropCourse(@RequestBody StudentDropCourseDTO studentDropCourseDTO){
        studentService.studentDropCourse(studentDropCourseDTO);
        return Result.success("退课成功");
    }

    /**
     * 学生批量退课的请求
     * @return
     */
    @PostMapping("/studentDropCourseOnList")
    public Result studentDropCourseOnList(@RequestBody IDListDTO idListDTO){
        studentService.studentDropCourseOnList(idListDTO);
        return Result.success("退课成功");
    }

    /**
     * 学生评价课程
     * @return
     */
    @PostMapping("/studentCommentCourse")
    public Result studentCommentCourse(@RequestBody StudentCommentCourseDTO studentCommentCourseDTO){
        studentService.studentCommentCourse(studentCommentCourseDTO);
        return Result.success();
    }

    /**
     * 学生查看自己课程的请求
     * @return
     */
    @PostMapping("/getStudentCourseList")
    public Result<StudentCourseListVO> getStudentCourse(@RequestBody GetStudentCourseListDTO getStudentCourseListDTO){
        StudentCourseListVO studentCourseListVO = studentService.getStudentCourseList(getStudentCourseListDTO);
        return Result.success(studentCourseListVO);
    }

    /**
     * 学生获取已结课的未评价的课程信息
     * @return
     */
    @PostMapping("/getStudentCourseCommentList")
    public Result<StudentCourseCommentListVO> getStudentCourseCommentList(@RequestBody GetStudentCourseCommentListDTO getStudentCourseListDTO){
        StudentCourseCommentListVO studentCourseCommentListVO = studentService.getStudentCourseCommentList(getStudentCourseListDTO);
        return Result.success(studentCourseCommentListVO);
    }

    /**
     * 学生获取自己的个人信息
     * @return
     */
    @PostMapping("/getStudentDetail")
    public Result<StudentInfoVO> getStudentDetail(){
        StudentInfoVO studentInfoVO = studentService.getStudentDetail();
        return Result.success(studentInfoVO);
    }

    /**
     * 学生更新自己的个人信息
     * @return
     */
    @PostMapping("/updateStudentInfo")
    public Result updateStudentInfo(@RequestBody StudentNewInfoDTO studentNewInfoDTO){
        studentService.updateStudentInfo(studentNewInfoDTO);
        return Result.success();
    }
}

